package com.smashcrush.client.gwt.client.editor;


import com.google.gwt.gen2.table.client.AbstractColumnDefinition;
import com.google.gwt.gen2.table.client.property.FooterProperty;
import com.smashcrush.model.Script;

/**
 * An {@link AbstractColumnDefinition} applied to {@link Student} row values.
 * 
 * @param <ColType>
 *            the data type of the column
 */
public abstract class ScriptColumnDefinition<ColType> extends
		AbstractColumnDefinition<Script, ColType> {
	/**
	 * Dynamic {@link FooterProperty} used with students.
	 */
	static class StudentFooterProperty extends FooterProperty {
		public StudentFooterProperty() {
			setFooterCount(1);
		}

		@Override
		public Object getFooter(int row, int column) {
			if (row == 0) {
				return "Col " + column;
			}
			return null;
		}
	}

	/**
	 * The general grouping of the column definition.
	 */
	public static enum Group {
		GENERAL("General Info"), SCHOOL("School Info"), LOGIN("Login Info");

		private String name;

		private Group(String name) {
			this.name = name;
		}

		/**
		 * @return the name of the group
		 */
		public String getName() {
			return name;
		}
	}

	/**
	 * Construct a new {@link ScriptColumnDefinition}.
	 * 
	 * @param name
	 *            the name of the column
	 * @param group
	 *            the column group
	 */
	public ScriptColumnDefinition(String name, Group group) {
		setHeader(0, name);
//		if (group == null) {
//			setHeader(1, name);
//		} else {
//			setHeader(1, group.getName());
//		}
//		setHeader(2, "User Information");

		// Setup the footer property
		setColumnProperty(FooterProperty.TYPE, new StudentFooterProperty());
	}
}